// MFCLab2View.h : interface of the CMFCLab2View class
//


#pragma once
#include "GeometricObject.h"
#include "Line.h"
#include "Rectangle.h"
#include "Circle.h"
#include "Triangle.h"
#include "Sphere.h"
#include "Cube.h"
#include "Cylinder.h"
#include "Torus.h"
enum STATE {SELECT, LINE, RECTANGLE, CIRCLE, POLYGON, CUBE, SPHERE, CYLINDER, TORUS};
enum MODE {TWO_D, THREE_D};

#define BUFSIZE 512

class CMFCLab2View : public CView
{
protected: // create from serialization only
	CMFCLab2View();
	DECLARE_DYNCREATE(CMFCLab2View)

// Attributes
public:
	CMFCLab2Doc* GetDocument() const;

// Operations
public:

// Overrides
public:
	virtual void OnDraw(CDC* pDC);  // overridden to draw this view
	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
	virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
	virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
	virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);

// Implementation
public:
	virtual ~CMFCLab2View();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

protected:

// Generated message map functions
protected:
	DECLARE_MESSAGE_MAP()
public:
	void SetupOpenGL(void);
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg void OnPaint();
	void RemoveOpenGL(void);	
	afx_msg void OnDestroy();
	void PaintScreen(GLenum mode);
private:
	HGLRC m_hRC;
	CGeometricObject* m_listObjects[100]; //manage geometric objects
	int m_numObject; // the number of geometric objects
	void InitParameters(void);
	void SetupViewport();
	bool m_isMouseDown;
	enum STATE m_state;
	enum MODE m_mode;
	GLdouble m_width;
	GLdouble m_height;
	GLsizei m_windowWidth;
	GLsizei m_windowHeight;
	GLdouble m_aspect;
	float camera2d_location_z;
	float camera3d_location_x;
	float camera3d_location_y;
	float camera3d_location_z;
	CPoint lastPoint;
public:
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	afx_msg void OnToolBarButtonSelect();
	afx_msg void OnToolBarButtonLine();
	afx_msg void OnToolBarButtonRectangle();
	afx_msg void OnToolBarButtonCircle();
	afx_msg void OnToolBarButtonPolygon();
	afx_msg void OnToolBarButtonCube();
	afx_msg void OnToolBarButtonSphere();
	afx_msg void OnToolBarButtonCylinder();
	afx_msg void OnToolBarButtonTorus();
	afx_msg void OnUpdateToolBarButtonSelect(CCmdUI* );
	afx_msg void OnUpdateToolBarButtonLine(CCmdUI* );
	afx_msg void OnUpdateToolBarButtonRectangle(CCmdUI* );
	afx_msg void OnUpdateToolBarButtonCircle(CCmdUI* );
	afx_msg void OnUpdateToolBarButtonPolygon(CCmdUI* );
	afx_msg void OnUpdateToolBarButtonCube(CCmdUI* );
	afx_msg void OnUpdateToolBarButtonSphere(CCmdUI* );
	afx_msg void OnUpdateToolBarButtonCylinder(CCmdUI* );
	afx_msg void OnUpdateToolBarButtonTorus(CCmdUI* );

	afx_msg void OnView2D();
	afx_msg void OnView3D();
	afx_msg void OnUpdateView2D(CCmdUI* );
	afx_msg void OnUpdateView3D(CCmdUI* );
	

	afx_msg void OnTimer(UINT_PTR nIDEvent);
	afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
};

#ifndef _DEBUG  // debug version in MFCLab2View.cpp
inline CMFCLab2Doc* CMFCLab2View::GetDocument() const
   { return reinterpret_cast<CMFCLab2Doc*>(m_pDocument); }
#endif

